home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / game / shoot / ADoom_src_1_2.lha / ADoom_src / st_stuff.c < prev    next >
C/C++ Source or Header  |  1998-03-09  |  38KB  |  1,479 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //      Status bar code.
  21. //      Does the face/direction indicator animatin.
  22. //      Does palette indicators as well (red pain/berserk, bright pickup)
  23. //
  24. //-----------------------------------------------------------------------------
  25.  
  26. static const char
  27. rcsid[] = "$Id: st_stuff.c,v 1.6 1997/02/03 22:45:13 b1 Exp $";
  28.  
  29.  
  30. #include <stdio.h>
  31.  
  32. #include "i_system.h"
  33. #include "i_video.h"
  34. #include "z_zone.h"
  35. #include "m_random.h"
  36. #include "w_wad.h"
  37.  
  38. #include "doomdef.h"
  39.  
  40. #include "g_game.h"
  41.  
  42. #include "st_stuff.h"
  43. #include "st_lib.h"
  44. #include "r_local.h"
  45.  
  46. #include "p_local.h"
  47. #include "p_inter.h"
  48.  
  49. #include "am_map.h"
  50. #include "m_cheat.h"
  51.  
  52. #include "s_sound.h"
  53.  
  54. // Needs access to LFB.
  55. #include "v_video.h"
  56.  
  57. // State.
  58. #include "doomstat.h"
  59.  
  60. // Data.
  61. #include "dstrings.h"
  62. #include "sounds.h"
  63.  
  64. //
  65. // STATUS BAR DATA
  66. //
  67.  
  68.  
  69. // Palette indices.
  70. // For damage/bonus red-/gold-shifts
  71. #define STARTREDPALS            1
  72. #define STARTBONUSPALS          9
  73. #define NUMREDPALS                      8
  74. #define NUMBONUSPALS            4
  75. // Radiation suit, green shift.
  76. #define RADIATIONPAL            13
  77.  
  78. // N/256*100% probability
  79. //  that the normal face state will change
  80. #define ST_FACEPROBABILITY              96
  81.  
  82. // For Responder
  83. #define ST_TOGGLECHAT           KEY_ENTER
  84.  
  85. // Location of status bar
  86. #define ST_X                            (((SCREENWIDTH-320)/2)+0)
  87. #define ST_X2                           (((SCREENWIDTH-320)/2)+104)
  88.  
  89. #define ST_FX                   (((SCREENWIDTH-320)/2)+143)
  90. #define ST_FY                   (SCREENHEIGHT-(200-169))
  91.  
  92. // Should be set to patch width
  93. //  for tall numbers later on
  94. #define ST_TALLNUMWIDTH         (tallnum[0]->width)
  95.  
  96. // Number of status faces.
  97. #define ST_NUMPAINFACES         5
  98. #define ST_NUMSTRAIGHTFACES     3
  99. #define ST_NUMTURNFACES         2
  100. #define ST_NUMSPECIALFACES              3
  101.  
  102. #define ST_FACESTRIDE \
  103.           (ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)
  104.  
  105. #define ST_NUMEXTRAFACES                2
  106.  
  107. #define ST_NUMFACES \
  108.           (ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)
  109.  
  110. #define ST_TURNOFFSET           (ST_NUMSTRAIGHTFACES)
  111. #define ST_OUCHOFFSET           (ST_TURNOFFSET + ST_NUMTURNFACES)
  112. #define ST_EVILGRINOFFSET               (ST_OUCHOFFSET + 1)
  113. #define ST_RAMPAGEOFFSET                (ST_EVILGRINOFFSET + 1)
  114. #define ST_GODFACE                      (ST_NUMPAINFACES*ST_FACESTRIDE)
  115. #define ST_DEADFACE                     (ST_GODFACE+1)
  116.  
  117. #define ST_FACESX                       (((SCREENWIDTH-320)/2)+143)
  118. #define ST_FACESY                       (SCREENHEIGHT-(200-168))
  119.  
  120. #define ST_EVILGRINCOUNT                (2*TICRATE)
  121. #define ST_STRAIGHTFACECOUNT    (TICRATE/2)
  122. #define ST_TURNCOUNT            (1*TICRATE)
  123. #define ST_OUCHCOUNT            (1*TICRATE)
  124. #define ST_RAMPAGEDELAY         (2*TICRATE)
  125.  
  126. #define ST_MUCHPAIN                     20
  127.  
  128.  
  129. // Location and size of statistics,
  130. //  justified according to widget type.
  131. // Problem is, within which space? STbar? Screen?
  132. // Note: this could be read in by a lump.
  133. //       Problem is, is the stuff rendered
  134. //       into a buffer,
  135. //       or into the frame buffer?
  136.  
  137. // AMMO number pos.
  138. #define ST_AMMOWIDTH            3       
  139. #define ST_AMMOX                        (((SCREENWIDTH-320)/2)+44)
  140. #define ST_AMMOY                        (SCREENHEIGHT-(200-171))
  141.  
  142. // HEALTH number pos.
  143. #define ST_HEALTHWIDTH          3       
  144. #define ST_HEALTHX                      (((SCREENWIDTH-320)/2)+90)
  145. #define ST_HEALTHY                      (SCREENHEIGHT-(200-171))
  146.  
  147. // Weapon pos.
  148. #define ST_ARMSX                        (((SCREENWIDTH-320)/2)+111)
  149. #define ST_ARMSY                        (SCREENHEIGHT-(200-172))
  150. #define ST_ARMSBGX                      (((SCREENWIDTH-320)/2)+104)
  151. #define ST_ARMSBGY                      (SCREENHEIGHT-(200-168))
  152. #define ST_ARMSXSPACE           12
  153. #define ST_ARMSYSPACE           10
  154.  
  155. // Frags pos.
  156. #define ST_FRAGSX                       (((SCREENWIDTH-320)/2)+138)
  157. #define ST_FRAGSY                       (SCREENHEIGHT-(200-171))
  158. #define ST_FRAGSWIDTH           2
  159.  
  160. // ARMOR number pos.
  161. #define ST_ARMORWIDTH           3
  162. #define ST_ARMORX                       (((SCREENWIDTH-320)/2)+221)
  163. #define ST_ARMORY                       (SCREENHEIGHT-(200-171))
  164.  
  165. // Key icon positions.
  166. #define ST_KEY0WIDTH            8
  167. #define ST_KEY0HEIGHT           5
  168. #define ST_KEY0X                        (((SCREENWIDTH-320)/2)+239)
  169. #define ST_KEY0Y                        (SCREENHEIGHT-(200-171))
  170. #define ST_KEY1WIDTH            ST_KEY0WIDTH
  171. #define ST_KEY1X                        (((SCREENWIDTH-320)/2)+239)
  172. #define ST_KEY1Y                        (SCREENHEIGHT-(200-181))
  173. #define ST_KEY2WIDTH            ST_KEY0WIDTH
  174. #define ST_KEY2X                        (((SCREENWIDTH-320)/2)+239)
  175. #define ST_KEY2Y                        (SCREENHEIGHT-(200-191))
  176.  
  177. // Ammunition counter.
  178. #define ST_AMMO0WIDTH           3
  179. #define ST_AMMO0HEIGHT          6
  180. #define ST_AMMO0X                       (((SCREENWIDTH-320)/2)+288)
  181. #define ST_AMMO0Y                       (SCREENHEIGHT-(200-173))
  182. #define ST_AMMO1WIDTH           ST_AMMO0WIDTH
  183. #define ST_AMMO1X                       (((SCREENWIDTH-320)/2)+288)
  184. #define ST_AMMO1Y                       (SCREENHEIGHT-(200-179))
  185. #define ST_AMMO2WIDTH           ST_AMMO0WIDTH
  186. #define ST_AMMO2X                       (((SCREENWIDTH-320)/2)+288)
  187. #define ST_AMMO2Y                       (SCREENHEIGHT-(200-191))
  188. #define ST_AMMO3WIDTH           ST_AMMO0WIDTH
  189. #define ST_AMMO3X                       (((SCREENWIDTH-320)/2)+288)
  190. #define ST_AMMO3Y                       (SCREENHEIGHT-(200-185))
  191.  
  192. // Indicate maximum ammunition.
  193. // Only needed because backpack exists.
  194. #define ST_MAXAMMO0WIDTH                3
  195. #define ST_MAXAMMO0HEIGHT               5
  196. #define ST_MAXAMMO0X            (((SCREENWIDTH-320)/2)+314)
  197. #define ST_MAXAMMO0Y            (SCREENHEIGHT-(200-173))
  198. #define ST_MAXAMMO1WIDTH                ST_MAXAMMO0WIDTH
  199. #define ST_MAXAMMO1X            (((SCREENWIDTH-320)/2)+314)
  200. #define ST_MAXAMMO1Y            (SCREENHEIGHT-(200-179))
  201. #define ST_MAXAMMO2WIDTH                ST_MAXAMMO0WIDTH
  202. #define ST_MAXAMMO2X            (((SCREENWIDTH-320)/2)+314)
  203. #define ST_MAXAMMO2Y            (SCREENHEIGHT-(200-191))
  204. #define ST_MAXAMMO3WIDTH                ST_MAXAMMO0WIDTH
  205. #define ST_MAXAMMO3X            (((SCREENWIDTH-320)/2)+314)
  206. #define ST_MAXAMMO3Y            (SCREENHEIGHT-(200-185))
  207.  
  208. // pistol
  209. #define ST_WEAPON0X                     (((SCREENWIDTH-320)/2)+110)
  210. #define ST_WEAPON0Y                     (SCREENHEIGHT-(200-172))
  211.  
  212. // shotgun
  213. #define ST_WEAPON1X                     (((SCREENWIDTH-320)/2)+122)
  214. #define ST_WEAPON1Y                     (SCREENHEIGHT-(200-172))
  215.  
  216. // chain gun
  217. #define ST_WEAPON2X                     (((SCREENWIDTH-320)/2)+134)
  218. #define ST_WEAPON2Y                     (SCREENHEIGHT-(200-172))
  219.  
  220. // missile launcher
  221. #define ST_WEAPON3X                     (((SCREENWIDTH-320)/2)+110)
  222. #define ST_WEAPON3Y                     (SCREENHEIGHT-(200-181))
  223.  
  224. // plasma gun
  225. #define ST_WEAPON4X                     (((SCREENWIDTH-320)/2)+122)
  226. #define ST_WEAPON4Y                     (SCREENHEIGHT-(200-181))
  227.  
  228.  // bfg
  229. #define ST_WEAPON5X                     (((SCREENWIDTH-320)/2)+134)
  230. #define ST_WEAPON5Y                     (SCREENHEIGHT-(200-181))
  231.  
  232. // WPNS title
  233. #define ST_WPNSX                        (((SCREENWIDTH-320)/2)+109)
  234. #define ST_WPNSY                        (SCREENHEIGHT-(200-191))
  235.  
  236.  // DETH title
  237. #define ST_DETHX                        (((SCREENWIDTH-320)/2)+109)
  238. #define ST_DETHY                        (SCREENHEIGHT-(200-191))
  239.  
  240. //Incoming messages window location
  241. //UNUSED
  242. // #define ST_MSGTEXTX     (viewwindowx)
  243. // #define ST_MSGTEXTY     (viewwindowy+viewheight-18)
  244. #define ST_MSGTEXTX                     0
  245. #define ST_MSGTEXTY                     0
  246. // Dimensions given in characters.
  247. #define ST_MSGWIDTH                     52
  248. // Or shall I say, in lines?
  249. #define ST_MSGHEIGHT            1
  250.  
  251. #define ST_OUTTEXTX                     0
  252. #define ST_OUTTEXTY                     6
  253.  
  254. // Width, in characters again.
  255. #define ST_OUTWIDTH                     52 
  256.  // Height, in lines. 
  257. #define ST_OUTHEIGHT            1
  258.  
  259. #define ST_MAPWIDTH     \
  260.     (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)]))
  261.  
  262. #define ST_MAPTITLEX \
  263.     (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)
  264.  
  265. #define ST_MAPTITLEY            0
  266. #define ST_MAPHEIGHT            1
  267.  
  268.             
  269. // main player in game
  270. static player_t*        plyr; 
  271.  
  272. // ST_Start() has just been called
  273. static boolean          st_firsttime;
  274.  
  275. // used to execute ST_Init() only once
  276. static int              veryfirsttime = 1;
  277.  
  278. // lump number for PLAYPAL
  279. static int              lu_palette;
  280.  
  281. // used for timing
  282. static unsigned int     st_clock;
  283.  
  284. // used for making messages go away
  285. static int              st_msgcounter=0;
  286.  
  287. // used when in chat 
  288. static st_chatstateenum_t       st_chatstate;
  289.  
  290. // whether in automap or first-person
  291. static st_stateenum_t   st_gamestate;
  292.  
  293. // whether left-side main status bar is active
  294. static boolean          st_statusbaron;
  295.  
  296. // whether status bar chat is active
  297. static boolean          st_chat;
  298.  
  299. // value of st_chat before message popped up
  300. static boolean          st_oldchat;
  301.  
  302. // whether chat window has the cursor on
  303. static boolean          st_cursoron;
  304.  
  305. // !deathmatch
  306. static boolean          st_notdeathmatch; 
  307.  
  308. // !deathmatch && st_statusbaron
  309. static boolean          st_armson;
  310.  
  311. // !deathmatch
  312. static boolean          st_fragson; 
  313.  
  314. // main bar left
  315. static patch_t*         sbar;
  316.  
  317. // 0-9, tall numbers
  318. static patch_t*         tallnum[10];
  319.  
  320. // tall % sign
  321. static patch_t*         tallpercent;
  322.  
  323. // 0-9, short, yellow (,different!) numbers
  324. static patch_t*         shortnum[10];
  325.  
  326. // 3 key-cards, 3 skulls
  327. static patch_t*         keys[NUMCARDS]; 
  328.  
  329. // face status patches
  330. static patch_t*         faces[ST_NUMFACES];
  331.  
  332. // face background
  333. static patch_t*         faceback;
  334.  
  335.  // main bar right
  336. static patch_t*         armsbg;
  337.  
  338. // weapon ownership patches
  339. static patch_t*         arms[6][2]; 
  340.  
  341. // ready-weapon widget
  342. static st_number_t      w_ready;
  343.  
  344.  // in deathmatch only, summary of frags stats
  345. static st_number_t      w_frags;
  346.  
  347. // health widget
  348. static st_percent_t     w_health;
  349.  
  350. // arms background
  351. static st_binicon_t     w_armsbg; 
  352.  
  353.  
  354. // weapon ownership widgets
  355. static st_multicon_t    w_arms[6];
  356.  
  357. // face status widget
  358. static st_multicon_t    w_faces; 
  359.  
  360. // keycard widgets
  361. static st_multicon_t    w_keyboxes[3];
  362.  
  363. // armor widget
  364. static st_percent_t     w_armor;
  365.  
  366. // ammo widgets
  367. static st_number_t      w_ammo[4];
  368.  
  369. // max ammo widgets
  370. static st_number_t      w_maxammo[4]; 
  371.  
  372.  
  373.  
  374.  // number of frags so far in deathmatch
  375. static int      st_fragscount;
  376.  
  377. // used to use appopriately pained face
  378. static int      st_oldhealth = -1;
  379.  
  380. // used for evil grin
  381. static boolean  oldweaponsowned[NUMWEAPONS]; 
  382.  
  383.  // count until face changes
  384. static int      st_facecount = 0;
  385.  
  386. // current face index, used by w_faces
  387. static int      st_faceindex = 0;
  388.  
  389. // holds key-type for each key box on bar
  390. static int      keyboxes[3]; 
  391.  
  392. // a random number per tick
  393. static int      st_randomnumber;  
  394.  
  395.  
  396.  
  397. // Massive bunches of cheat shit
  398. //  to keep it from being easy to figure them out.
  399. // Yeah, right...
  400. unsigned char   cheat_mus_seq[] =
  401. {
  402.     0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff
  403. };
  404.  
  405. unsigned char   cheat_choppers_seq[] =
  406. {
  407.     0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff // id...
  408. };
  409.  
  410. unsigned char   cheat_god_seq[] =
  411. {
  412.     0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff  // iddqd
  413. };
  414.  
  415. unsigned char   cheat_ammo_seq[] =
  416. {
  417.     0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff  // idkfa
  418. };
  419.  
  420. unsigned char   cheat_ammonokey_seq[] =
  421. {
  422.     0xb2, 0x26, 0x66, 0xa2, 0xff        // idfa
  423. };
  424.  
  425.  
  426. // Smashing Pumpkins Into Samml Piles Of Putried Debris. 
  427. unsigned char   cheat_noclip_seq[] =
  428. {
  429.     0xb2, 0x26, 0xea, 0x2a, 0xb2,       // idspispopd
  430.     0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff
  431. };
  432.  
  433. //
  434. unsigned char   cheat_commercial_noclip_seq[] =
  435. {
  436.     0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff    // idclip
  437. }; 
  438.  
  439.  
  440.  
  441. unsigned char   cheat_powerup_seq[7][10] =
  442. {
  443.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff },     // beholdv
  444.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff },     // beholds
  445.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff },     // beholdi
  446.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff },     // beholdr
  447.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff },     // beholda
  448.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff },     // beholdl
  449.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff }            // behold
  450. };
  451.  
  452.  
  453. unsigned char   cheat_clev_seq[] =
  454. {
  455.     0xb2, 0x26,  0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff  // idclev
  456. };
  457.  
  458.  
  459. // my position cheat
  460. unsigned char   cheat_mypos_seq[] =
  461. {
  462.     0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff      // idmypos
  463. }; 
  464.  
  465.  
  466. // Now what?
  467. cheatseq_t      cheat_mus = { cheat_mus_seq, 0 };
  468. cheatseq_t      cheat_god = { cheat_god_seq, 0 };
  469. cheatseq_t      cheat_ammo = { cheat_ammo_seq, 0 };
  470. cheatseq_t      cheat_ammonokey = { cheat_ammonokey_seq, 0 };
  471. cheatseq_t      cheat_noclip = { cheat_noclip_seq, 0 };
  472. cheatseq_t      cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 };
  473.  
  474. cheatseq_t      cheat_powerup[7] =
  475. {
  476.     { cheat_powerup_seq[0], 0 },
  477.     { cheat_powerup_seq[1], 0 },
  478.     { cheat_powerup_seq[2], 0 },
  479.     { cheat_powerup_seq[3], 0 },
  480.     { cheat_powerup_seq[4], 0 },
  481.     { cheat_powerup_seq[5], 0 },
  482.     { cheat_powerup_seq[6], 0 }
  483. };
  484.  
  485. cheatseq_t      cheat_choppers = { cheat_choppers_seq, 0 };
  486. cheatseq_t      cheat_clev = { cheat_clev_seq, 0 };
  487. cheatseq_t      cheat_mypos = { cheat_mypos_seq, 0 };
  488.  
  489.  
  490. // 
  491. extern char*    mapnames[];
  492.  
  493.  
  494. //
  495. // STATUS BAR CODE
  496. //
  497. void ST_Stop(void);
  498.  
  499. void ST_refreshBackground(void)
  500. {
  501.  
  502.     if (st_statusbaron)
  503.     {
  504.         V_DrawPatch(ST_X, 0, BG, sbar);
  505.  
  506.         if (netgame)
  507.             V_DrawPatch(ST_FX, 0, BG, faceback);
  508.  
  509.         V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);
  510.     }
  511.  
  512. }
  513.  
  514. // Dehcked
  515. int idfa_armor=200;
  516. int idfa_armor_class=2;
  517. int idkfa_armor=200;
  518. int idkfa_armor_class=2;
  519. int god_health=100;
  520.  
  521.  
  522. // Respond to keyboard input events,
  523. //  intercept cheats.
  524. boolean
  525. ST_Responder (event_t* ev)
  526. {
  527.   int           i;
  528.     
  529.   // Filter automap on/off.
  530.   if (ev->type == ev_keyup
  531.       && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
  532.   {
  533.     switch(ev->data1)
  534.     {
  535.       case AM_MSGENTERED:
  536.         st_gamestate = AutomapState;
  537.         st_firsttime = true;
  538.         break;
  539.         
  540.       case AM_MSGEXITED:
  541.         //      fprintf(stderr, "AM exited\n");
  542.         st_gamestate = FirstPersonState;
  543.         break;
  544.     }
  545.   }
  546.  
  547.   // if a user keypress...
  548.   else if (ev->type == ev_keydown)
  549.   {
  550.     if (!netgame)
  551.     {
  552.       // b. - enabled for more debug fun.
  553.       // if (gameskill != sk_nightmare) {
  554.       
  555.       // 'dqd' cheat for toggleable god mode
  556.       if (cht_CheckCheat(&cheat_god, ev->data1))
  557.       {
  558.         plyr->cheats ^= CF_GODMODE;
  559.         if (plyr->cheats & CF_GODMODE)
  560.         {
  561.           if (plyr->mo)
  562.             plyr->mo->health = god_health; // Dehacked
  563.           
  564.           plyr->health = god_health; // Dehacked
  565.           plyr->message = STSTR_DQDON;
  566.         }
  567.         else 
  568.           plyr->message = STSTR_DQDOFF;
  569.       }
  570.       // 'fa' cheat for killer fucking arsenal
  571.       else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
  572.       {
  573.         plyr->armorpoints = idfa_armor; // Dehacked
  574.         plyr->armortype = idfa_armor_class; // Dehacked
  575.         
  576.         for (i=0;i<NUMWEAPONS;i++)
  577.           plyr->weaponowned[i] = true;
  578.         
  579.         for (i=0;i<NUMAMMO;i++)
  580.           plyr->ammo[i] = plyr->maxammo[i];
  581.         
  582.         plyr->message = STSTR_FAADDED;
  583.       }
  584.       // 'kfa' cheat for key full ammo
  585.       else if (cht_CheckCheat(&cheat_ammo, ev->data1))
  586.       {
  587.         plyr->armorpoints = idkfa_armor;
  588.         plyr->armortype = idkfa_armor_class;
  589.         
  590.         for (i=0;i<NUMWEAPONS;i++)
  591.           plyr->weaponowned[i] = true;
  592.         
  593.         for (i=0;i<NUMAMMO;i++)
  594.           plyr->ammo[i] = plyr->maxammo[i];
  595.         
  596.         for (i=0;i<NUMCARDS;i++)
  597.           plyr->cards[i] = true;
  598.         
  599.         plyr->message = STSTR_KFAADDED;
  600.       }
  601.       // 'mus' cheat for changing music
  602.       else if (cht_CheckCheat(&cheat_mus, ev->data1))
  603.       {
  604.         
  605.         char    buf[3];
  606.         int             musnum;
  607.         
  608.         plyr->message = STSTR_MUS;
  609.         cht_GetParam(&cheat_mus, buf);
  610.         
  611.         if (gamemode == commercial)
  612.         {
  613.           musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
  614.           
  615.           if (((buf[0]-'0')*10 + buf[1]-'0') > 35)
  616.             plyr->message = STSTR_NOMUS;
  617.           else
  618.             S_ChangeMusic(musnum, 1);
  619.         }
  620.         else
  621.         {
  622.           musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
  623.           
  624.           if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
  625.             plyr->message = STSTR_NOMUS;
  626.           else
  627.             S_ChangeMusic(musnum, 1);
  628.         }
  629.       }
  630.       // Simplified, accepting both "noclip" and "idspispopd".
  631.       // no clipping mode cheat
  632.       else if ( cht_CheckCheat(&cheat_noclip, ev->data1) 
  633.                 || cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
  634.       { 
  635.         plyr->cheats ^= CF_NOCLIP;
  636.         
  637.         if (plyr->cheats & CF_NOCLIP)
  638.           plyr->message = STSTR_NCON;
  639.         else
  640.           plyr->message = STSTR_NCOFF;
  641.       }
  642.       // 'behold?' power-up cheats
  643.       for (i=0;i<6;i++)
  644.       {
  645.         if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
  646.         {
  647.           if (!plyr->powers[i])
  648.             P_GivePower( plyr, i);
  649.           else if (i!=pw_strength)
  650.             plyr->powers[i] = 1;
  651.           else
  652.             plyr->powers[i] = 0;
  653.           
  654.           plyr->message = STSTR_BEHOLDX;
  655.         }
  656.       }
  657.       
  658.       // 'behold' power-up menu
  659.       if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
  660.       {
  661.         plyr->message = STSTR_BEHOLD;
  662.       }
  663.       // 'choppers' invulnerability & chainsaw
  664.       else if (cht_CheckCheat(&cheat_choppers, ev->data1))
  665.       {
  666.         plyr->weaponowned[wp_chainsaw] = true;
  667.         plyr->powers[pw_invulnerability] = true;
  668.         plyr->message = STSTR_CHOPPERS;
  669.       }
  670.       // 'mypos' for player position
  671.       else if (cht_CheckCheat(&cheat_mypos, ev->data1))
  672.       {
  673.         static char     buf[ST_MSGWIDTH];
  674.         sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
  675.                 players[consoleplayer].mo->angle,
  676.                 players[consoleplayer].mo->x,
  677.                 players[consoleplayer].mo->y);
  678.         plyr->message = buf;
  679.       }
  680.     }
  681.     
  682.     // 'clev' change-level cheat
  683.     if (cht_CheckCheat(&cheat_clev, ev->data1))
  684.     {
  685.       char              buf[3];
  686.       int               epsd;
  687.       int               map;
  688.       
  689.       cht_GetParam(&cheat_clev, buf);
  690.       
  691.       if (gamemode == commercial)
  692.       {
  693.     epsd = 1;  /* changed from 0 by Peter McGavin, 28 Feb 1998 */
  694.         map = (buf[0] - '0')*10 + buf[1] - '0';
  695.       }
  696.       else
  697.       {
  698.         epsd = buf[0] - '0';
  699.         map = buf[1] - '0';
  700.       }
  701.  
  702.       // Catch invalid maps.
  703.       if (epsd < 1)
  704.         return false;
  705.  
  706.       if (map < 1)
  707.         return false;
  708.       
  709.       // Ohmygod - this is not going to work.
  710.       if ((gamemode == retail)
  711.           && ((epsd > 4) || (map > 9)))
  712.         return false;
  713.  
  714.       if ((gamemode == registered)
  715.           && ((epsd > 3) || (map > 9)))
  716.         return false;
  717.  
  718.       if ((gamemode == shareware)
  719.           && ((epsd > 1) || (map > 9)))
  720.         return false;
  721.  
  722.       if ((gamemode == commercial)
  723.         && (( epsd > 1) || (map > 34)))
  724.         return false;
  725.  
  726.       // So be it.
  727.       plyr->message = STSTR_CLEV;
  728.       G_DeferedInitNew(gameskill, epsd, map);
  729.     }    
  730.   }
  731.   return false;
  732. }
  733.  
  734.  
  735.  
  736. int ST_calcPainOffset(void)
  737. {
  738.     int         health;
  739.     static int  lastcalc;
  740.     static int  oldhealth = -1;
  741.     
  742.     health = plyr->health > 100 ? 100 : plyr->health;
  743.  
  744.     if (health != oldhealth)
  745.     {
  746.         lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101);
  747.         oldhealth = health;
  748.     }
  749.     return lastcalc;
  750. }
  751.  
  752.  
  753. //
  754. // This is a not-very-pretty routine which handles
  755. //  the face states and their timing.
  756. // the precedence of expressions is:
  757. //  dead > evil grin > turned head > straight ahead
  758. //
  759. void ST_updateFaceWidget(void)
  760. {
  761.     int         i;
  762.     angle_t     badguyangle;
  763.     angle_t     diffang;
  764.     static int  lastattackdown = -1;
  765.     static int  priority = 0;
  766.     boolean     doevilgrin;
  767.  
  768.     if (priority < 10)
  769.     {
  770.         // dead
  771.         if (!plyr->health)
  772.         {
  773.             priority = 9;
  774.             st_faceindex = ST_DEADFACE;
  775.             st_facecount = 1;
  776.         }
  777.     }
  778.  
  779.     if (priority < 9)
  780.     {
  781.         if (plyr->bonuscount)
  782.         {
  783.             // picking up bonus
  784.             doevilgrin = false;
  785.  
  786.             for (i=0;i<NUMWEAPONS;i++)
  787.             {
  788.                 if (oldweaponsowned[i] != plyr->weaponowned[i])
  789.                 {
  790.                     doevilgrin = true;
  791.                     oldweaponsowned[i] = plyr->weaponowned[i];
  792.                 }
  793.             }
  794.             if (doevilgrin) 
  795.             {
  796.                 // evil grin if just picked up weapon
  797.                 priority = 8;
  798.                 st_facecount = ST_EVILGRINCOUNT;
  799.                 st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
  800.             }
  801.         }
  802.  
  803.     }
  804.   
  805.     if (priority < 8)
  806.     {
  807.         if (plyr->damagecount
  808.             && plyr->attacker
  809.             && plyr->attacker != plyr->mo)
  810.         {
  811.             // being attacked
  812.             priority = 7;
  813.             
  814.             if (plyr->health - st_oldhealth > ST_MUCHPAIN)
  815.             {
  816.                 st_facecount = ST_TURNCOUNT;
  817.                 st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
  818.             }
  819.             else
  820.             {
  821.                 badguyangle = R_PointToAngle2(plyr->mo->x,
  822.                                               plyr->mo->y,
  823.                                               plyr->attacker->x,
  824.                                               plyr->attacker->y);
  825.                 
  826.                 if (badguyangle > plyr->mo->angle)
  827.                 {
  828.                     // whether right or left
  829.                     diffang = badguyangle - plyr->mo->angle;
  830.                     i = diffang > ANG180; 
  831.                 }
  832.                 else
  833.                 {
  834.                     // whether left or right
  835.                     diffang = plyr->mo->angle - badguyangle;
  836.                     i = diffang <= ANG180; 
  837.                 } // confusing, aint it?
  838.  
  839.                 
  840.                 st_facecount = ST_TURNCOUNT;
  841.                 st_faceindex = ST_calcPainOffset();
  842.                 
  843.                 if (diffang < ANG45)
  844.                 {
  845.                     // head-on    
  846.                     st_faceindex += ST_RAMPAGEOFFSET;
  847.                 }
  848.                 else if (i)
  849.                 {
  850.                     // turn face right
  851.                     st_faceindex += ST_TURNOFFSET;
  852.                 }
  853.                 else
  854.                 {
  855.                     // turn face left
  856.                     st_faceindex += ST_TURNOFFSET+1;
  857.                 }
  858.             }
  859.         }
  860.     }
  861.   
  862.     if (priority < 7)
  863.     {
  864.         // getting hurt because of your own damn stupidity
  865.         if (plyr->damagecount)
  866.         {
  867.             if (plyr->health - st_oldhealth > ST_MUCHPAIN)
  868.             {
  869.                 priority = 7;
  870.                 st_facecount = ST_TURNCOUNT;
  871.                 st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
  872.             }
  873.             else
  874.             {
  875.                 priority = 6;
  876.                 st_facecount = ST_TURNCOUNT;
  877.                 st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
  878.             }
  879.  
  880.         }
  881.  
  882.     }
  883.   
  884.     if (priority < 6)
  885.     {
  886.         // rapid firing
  887.         if (plyr->attackdown)
  888.         {
  889.             if (lastattackdown==-1)
  890.                 lastattackdown = ST_RAMPAGEDELAY;
  891.             else if (!--lastattackdown)
  892.             {
  893.                 priority = 5;
  894.                 st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
  895.                 st_facecount = 1;
  896.                 lastattackdown = 1;
  897.             }
  898.         }
  899.         else
  900.             lastattackdown = -1;
  901.  
  902.     }
  903.   
  904.     if (priority < 5)
  905.     {
  906.         // invulnerability
  907.         if ((plyr->cheats & CF_GODMODE)
  908.             || plyr->powers[pw_invulnerability])
  909.         {
  910.             priority = 4;
  911.  
  912.             st_faceindex = ST_GODFACE;
  913.             st_facecount = 1;
  914.  
  915.         }
  916.  
  917.     }
  918.  
  919.     // look left or look right if the facecount has timed out
  920.     if (!st_facecount)
  921.     {
  922.         st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
  923.         st_facecount = ST_STRAIGHTFACECOUNT;
  924.         priority = 0;
  925.     }
  926.  
  927.     st_facecount--;
  928.  
  929. }
  930.  
  931. void ST_updateWidgets(void)
  932. {
  933.     static int  largeammo = 1994; // means "n/a"
  934.     int         i;
  935.  
  936.     // must redirect the pointer if the ready weapon has changed.
  937.     //  if (w_ready.data != plyr->readyweapon)
  938.     //  {
  939.     if (weaponinfo[plyr->readyweapon].ammo == am_noammo)
  940.         w_ready.num = &largeammo;
  941.     else
  942.         w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo];
  943.     //{
  944.     // static int tic=0;
  945.     // static int dir=-1;
  946.     // if (!(tic&15))
  947.     //   plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir;
  948.     // if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100)
  949.     //   dir = 1;
  950.     // tic++;
  951.     // }
  952.     w_ready.data = plyr->readyweapon;
  953.  
  954.     // if (*w_ready.on)
  955.     //  STlib_updateNum(&w_ready, true);
  956.     // refresh weapon change
  957.     //  }
  958.  
  959.     // update keycard multiple widgets
  960.     for (i=0;i<3;i++)
  961.     {
  962.         keyboxes[i] = plyr->cards[i] ? i : -1;
  963.  
  964.         if (plyr->cards[i+3])
  965.             keyboxes[i] = i+3;
  966.     }
  967.  
  968.     // refresh everything if this is him coming back to life
  969.     ST_updateFaceWidget();
  970.  
  971.     // used by the w_armsbg widget
  972.     st_notdeathmatch = !deathmatch;
  973.     
  974.     // used by w_arms[] widgets
  975.     st_armson = st_statusbaron && !deathmatch; 
  976.  
  977.     // used by w_frags widget
  978.     st_fragson = deathmatch && st_statusbaron; 
  979.     st_fragscount = 0;
  980.  
  981.     for (i=0 ; i<MAXPLAYERS ; i++)
  982.     {
  983.         if (i != consoleplayer)
  984.             st_fragscount += plyr->frags[i];
  985.         else
  986.             st_fragscount -= plyr->frags[i];
  987.     }
  988.  
  989.     // get rid of chat window if up because of message
  990.     if (!--st_msgcounter)
  991.         st_chat = st_oldchat;
  992.  
  993. }
  994.  
  995. void ST_Ticker (void)
  996. {
  997.  
  998.     st_clock++;
  999.     st_randomnumber = M_Random();
  1000.     ST_updateWidgets();
  1001.     st_oldhealth = plyr->health;
  1002.  
  1003. }
  1004.  
  1005. static int st_palette = 0;
  1006.  
  1007. void ST_doPaletteStuff(void)
  1008. {
  1009.  
  1010.     int         palette;
  1011.     byte*       pal;
  1012.     int         cnt;
  1013.     int         bzc;
  1014.  
  1015.     cnt = plyr->damagecount;
  1016.  
  1017.     if (plyr->powers[pw_strength])
  1018.     {
  1019.         // slowly fade the berzerk out
  1020.         bzc = 12 - (plyr->powers[pw_strength]>>6);
  1021.  
  1022.         if (bzc > cnt)
  1023.             cnt = bzc;
  1024.     }
  1025.         
  1026.     if (cnt)
  1027.     {
  1028.         palette = (cnt+7)>>3;
  1029.         
  1030.         if (palette >= NUMREDPALS)
  1031.             palette = NUMREDPALS-1;
  1032.  
  1033.         palette += STARTREDPALS;
  1034.     }
  1035.  
  1036.     else if (plyr->bonuscount)
  1037.     {
  1038.         palette = (plyr->bonuscount+7)>>3;
  1039.  
  1040.         if (palette >= NUMBONUSPALS)
  1041.             palette = NUMBONUSPALS-1;
  1042.  
  1043.         palette += STARTBONUSPALS;
  1044.     }
  1045.  
  1046.     else if ( plyr->powers[pw_ironfeet] > 4*32
  1047.               || plyr->powers[pw_ironfeet]&8)
  1048.         palette = RADIATIONPAL;
  1049.     else
  1050.         palette = 0;
  1051.  
  1052.     if (palette != st_palette)
  1053.     {
  1054.         st_palette = palette;
  1055.         pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768;
  1056.         I_SetPalette (pal, palette);
  1057.     }
  1058.  
  1059. }
  1060.  
  1061. void ST_drawWidgets(boolean refresh)
  1062. {
  1063.     int         i;
  1064.  
  1065.     // used by w_arms[] widgets
  1066.     st_armson = st_statusbaron && !deathmatch;
  1067.  
  1068.     // used by w_frags widget
  1069.     st_fragson = deathmatch && st_statusbaron; 
  1070.  
  1071.     STlib_updateNum(&w_ready, refresh);
  1072.  
  1073.     for (i=0;i<4;i++)
  1074.     {
  1075.         STlib_updateNum(&w_ammo[i], refresh);
  1076.         STlib_updateNum(&w_maxammo[i], refresh);
  1077.     }
  1078.  
  1079.     STlib_updatePercent(&w_health, refresh);
  1080.     STlib_updatePercent(&w_armor, refresh);
  1081.  
  1082.     STlib_updateBinIcon(&w_armsbg, refresh);
  1083.  
  1084.     for (i=0;i<6;i++)
  1085.         STlib_updateMultIcon(&w_arms[i], refresh);
  1086.  
  1087.     STlib_updateMultIcon(&w_faces, refresh);
  1088.  
  1089.     for (i=0;i<3;i++)
  1090.         STlib_updateMultIcon(&w_keyboxes[i], refresh);
  1091.  
  1092.     STlib_updateNum(&w_frags, refresh);
  1093.  
  1094. }
  1095.  
  1096. void ST_doRefresh(void)
  1097. {
  1098.  
  1099.     st_firsttime = false;
  1100.  
  1101.     // draw status bar background to off-screen buff
  1102.     ST_refreshBackground();
  1103.  
  1104.     // and refresh all widgets
  1105.     ST_drawWidgets(true);
  1106.  
  1107. }
  1108.  
  1109. void ST_diffDraw(void)
  1110. {
  1111.     // update all widgets
  1112.     ST_drawWidgets(false);
  1113. }
  1114.  
  1115. void ST_Drawer (boolean fullscreen, boolean refresh)
  1116. {
  1117.   
  1118.     st_statusbaron = (!fullscreen) || automapactive;
  1119.     st_firsttime = st_firsttime || refresh;
  1120.  
  1121.     // Do red-/gold-shifts from damage/items
  1122.     ST_doPaletteStuff();
  1123.  
  1124.     // If just after ST_Start(), refresh all
  1125.     if (st_firsttime) ST_doRefresh();
  1126.     // Otherwise, update as little as possible
  1127.     else ST_diffDraw();
  1128.  
  1129. }
  1130.  
  1131. void ST_loadGraphics(void)
  1132. {
  1133.  
  1134.     int         i;
  1135.     int         j;
  1136.     int         facenum;
  1137.     
  1138.     char        namebuf[9];
  1139.  
  1140.     // Load the numbers, tall and short
  1141.     for (i=0;i<10;i++)
  1142.     {
  1143.         sprintf(namebuf, "STTNUM%d", i);
  1144.         tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1145.  
  1146.         sprintf(namebuf, "STYSNUM%d", i);
  1147.         shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1148.     }
  1149.  
  1150.     // Load percent key.
  1151.     //Note: why not load STMINUS here, too?
  1152.     tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC);
  1153.  
  1154.     // key cards
  1155.     for (i=0;i<NUMCARDS;i++)
  1156.     {
  1157.         sprintf(namebuf, "STKEYS%d", i);
  1158.         keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1159.     }
  1160.  
  1161.     // arms background
  1162.     armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC);
  1163.  
  1164.     // arms ownership widgets
  1165.     for (i=0;i<6;i++)
  1166.     {
  1167.         sprintf(namebuf, "STGNUM%d", i+2);
  1168.  
  1169.         // gray #
  1170.         arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1171.  
  1172.         // yellow #
  1173.         arms[i][1] = shortnum[i+2]; 
  1174.     }
  1175.  
  1176.     // face backgrounds for different color players
  1177.     sprintf(namebuf, "STFB%d", consoleplayer);
  1178.     faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1179.  
  1180.     // status bar background bits
  1181.     sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC);
  1182.  
  1183.     // face states
  1184.     facenum = 0;
  1185.     for (i=0;i<ST_NUMPAINFACES;i++)
  1186.     {
  1187.         for (j=0;j<ST_NUMSTRAIGHTFACES;j++)
  1188.         {
  1189.             sprintf(namebuf, "STFST%d%d", i, j);
  1190.             faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1191.         }
  1192.         sprintf(namebuf, "STFTR%d0", i);        // turn right
  1193.         faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1194.         sprintf(namebuf, "STFTL%d0", i);        // turn left
  1195.         faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1196.         sprintf(namebuf, "STFOUCH%d", i);       // ouch!
  1197.         faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1198.         sprintf(namebuf, "STFEVL%d", i);        // evil grin ;)
  1199.         faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1200.         sprintf(namebuf, "STFKILL%d", i);       // pissed off
  1201.         faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1202.     }
  1203.     faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC);
  1204.     faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC);
  1205.  
  1206. }
  1207.  
  1208. void ST_loadData(void)
  1209. {
  1210.     lu_palette = W_GetNumForName ("PLAYPAL");
  1211.     ST_loadGraphics();
  1212. }
  1213.  
  1214. void ST_unloadGraphics(void)
  1215. {
  1216.  
  1217.     int i;
  1218.  
  1219.     // unload the numbers, tall and short
  1220.     for (i=0;i<10;i++)
  1221.     {
  1222.         Z_ChangeTag(tallnum[i], PU_CACHE);
  1223.         Z_ChangeTag(shortnum[i], PU_CACHE);
  1224.     }
  1225.     // unload tall percent
  1226.     Z_ChangeTag(tallpercent, PU_CACHE); 
  1227.  
  1228.     // unload arms background
  1229.     Z_ChangeTag(armsbg, PU_CACHE); 
  1230.  
  1231.     // unload gray #'s
  1232.     for (i=0;i<6;i++)
  1233.         Z_ChangeTag(arms[i][0], PU_CACHE);
  1234.     
  1235.     // unload the key cards
  1236.     for (i=0;i<NUMCARDS;i++)
  1237.         Z_ChangeTag(keys[i], PU_CACHE);
  1238.  
  1239.     Z_ChangeTag(sbar, PU_CACHE);
  1240.     Z_ChangeTag(faceback, PU_CACHE);
  1241.  
  1242.     for (i=0;i<ST_NUMFACES;i++)
  1243.         Z_ChangeTag(faces[i], PU_CACHE);
  1244.  
  1245.     // Note: nobody ain't seen no unloading
  1246.     //   of stminus yet. Dude.
  1247.     
  1248.  
  1249. }
  1250.  
  1251. void ST_unloadData(void)
  1252. {
  1253.     ST_unloadGraphics();
  1254. }
  1255.  
  1256. void ST_initData(void)
  1257. {
  1258.  
  1259.     int         i;
  1260.  
  1261.     st_firsttime = true;
  1262.     plyr = &players[consoleplayer];
  1263.  
  1264.     st_clock = 0;
  1265.     st_chatstate = StartChatState;
  1266.     st_gamestate = FirstPersonState;
  1267.  
  1268.     st_statusbaron = true;
  1269.     st_oldchat = st_chat = false;
  1270.     st_cursoron = false;
  1271.  
  1272.     st_faceindex = 0;
  1273.     st_palette = -1;
  1274.  
  1275.     st_oldhealth = -1;
  1276.  
  1277.     for (i=0;i<NUMWEAPONS;i++)
  1278.         oldweaponsowned[i] = plyr->weaponowned[i];
  1279.  
  1280.     for (i=0;i<3;i++)
  1281.         keyboxes[i] = -1;
  1282.  
  1283.     STlib_init();
  1284.  
  1285. }
  1286.  
  1287.  
  1288.  
  1289. void ST_createWidgets(void)
  1290. {
  1291.  
  1292.     int i;
  1293.  
  1294.     // ready weapon ammo
  1295.     STlib_initNum(&w_ready,
  1296.                   ST_AMMOX,
  1297.                   ST_AMMOY,
  1298.                   tallnum,
  1299.                   &plyr->ammo[weaponinfo[plyr->readyweapon].ammo],
  1300.                   &st_statusbaron,
  1301.                   ST_AMMOWIDTH );
  1302.  
  1303.     // the last weapon type
  1304.     w_ready.data = plyr->readyweapon; 
  1305.  
  1306.     // health percentage
  1307.     STlib_initPercent(&w_health,
  1308.                       ST_HEALTHX,
  1309.                       ST_HEALTHY,
  1310.                       tallnum,
  1311.                       &plyr->health,
  1312.                       &st_statusbaron,
  1313.                       tallpercent);
  1314.  
  1315.     // arms background
  1316.     STlib_initBinIcon(&w_armsbg,
  1317.                       ST_ARMSBGX,
  1318.                       ST_ARMSBGY,
  1319.                       armsbg,
  1320.                       &st_notdeathmatch,
  1321.                       &st_statusbaron);
  1322.  
  1323.     // weapons owned
  1324.     for(i=0;i<6;i++)
  1325.     {
  1326.         STlib_initMultIcon(&w_arms[i],
  1327.                            ST_ARMSX+(i%3)*ST_ARMSXSPACE,
  1328.                            ST_ARMSY+(i/3)*ST_ARMSYSPACE,
  1329.                            arms[i], (int *) &plyr->weaponowned[i+1],
  1330.                            &st_armson);
  1331.     }
  1332.  
  1333.     // frags sum
  1334.     STlib_initNum(&w_frags,
  1335.                   ST_FRAGSX,
  1336.                   ST_FRAGSY,
  1337.                   tallnum,
  1338.                   &st_fragscount,
  1339.                   &st_fragson,
  1340.                   ST_FRAGSWIDTH);
  1341.  
  1342.     // faces
  1343.     STlib_initMultIcon(&w_faces,
  1344.                        ST_FACESX,
  1345.                        ST_FACESY,
  1346.                        faces,
  1347.                        &st_faceindex,
  1348.                        &st_statusbaron);
  1349.  
  1350.     // armor percentage - should be colored later
  1351.     STlib_initPercent(&w_armor,
  1352.                       ST_ARMORX,
  1353.                       ST_ARMORY,
  1354.                       tallnum,
  1355.                       &plyr->armorpoints,
  1356.                       &st_statusbaron, tallpercent);
  1357.  
  1358.     // keyboxes 0-2
  1359.     STlib_initMultIcon(&w_keyboxes[0],
  1360.                        ST_KEY0X,
  1361.                        ST_KEY0Y,
  1362.                        keys,
  1363.                        &keyboxes[0],
  1364.                        &st_statusbaron);
  1365.     
  1366.     STlib_initMultIcon(&w_keyboxes[1],
  1367.                        ST_KEY1X,
  1368.                        ST_KEY1Y,
  1369.                        keys,
  1370.                        &keyboxes[1],
  1371.                        &st_statusbaron);
  1372.  
  1373.     STlib_initMultIcon(&w_keyboxes[2],
  1374.                        ST_KEY2X,
  1375.                        ST_KEY2Y,
  1376.                        keys,
  1377.                        &keyboxes[2],
  1378.                        &st_statusbaron);
  1379.  
  1380.     // ammo count (all four kinds)
  1381.     STlib_initNum(&w_ammo[0],
  1382.                   ST_AMMO0X,
  1383.                   ST_AMMO0Y,
  1384.                   shortnum,
  1385.                   &plyr->ammo[0],
  1386.                   &st_statusbaron,
  1387.                   ST_AMMO0WIDTH);
  1388.  
  1389.     STlib_initNum(&w_ammo[1],
  1390.                   ST_AMMO1X,
  1391.                   ST_AMMO1Y,
  1392.                   shortnum,
  1393.                   &plyr->ammo[1],
  1394.                   &st_statusbaron,
  1395.                   ST_AMMO1WIDTH);
  1396.  
  1397.     STlib_initNum(&w_ammo[2],
  1398.                   ST_AMMO2X,
  1399.                   ST_AMMO2Y,
  1400.                   shortnum,
  1401.                   &plyr->ammo[2],
  1402.                   &st_statusbaron,
  1403.                   ST_AMMO2WIDTH);
  1404.     
  1405.     STlib_initNum(&w_ammo[3],
  1406.                   ST_AMMO3X,
  1407.                   ST_AMMO3Y,
  1408.                   shortnum,
  1409.                   &plyr->ammo[3],
  1410.                   &st_statusbaron,
  1411.                   ST_AMMO3WIDTH);
  1412.  
  1413.     // max ammo count (all four kinds)
  1414.     STlib_initNum(&w_maxammo[0],
  1415.                   ST_MAXAMMO0X,
  1416.                   ST_MAXAMMO0Y,
  1417.                   shortnum,
  1418.                   &plyr->maxammo[0],
  1419.                   &st_statusbaron,
  1420.                   ST_MAXAMMO0WIDTH);
  1421.  
  1422.     STlib_initNum(&w_maxammo[1],
  1423.                   ST_MAXAMMO1X,
  1424.                   ST_MAXAMMO1Y,
  1425.                   shortnum,
  1426.                   &plyr->maxammo[1],
  1427.                   &st_statusbaron,
  1428.                   ST_MAXAMMO1WIDTH);
  1429.  
  1430.     STlib_initNum(&w_maxammo[2],
  1431.                   ST_MAXAMMO2X,
  1432.                   ST_MAXAMMO2Y,
  1433.                   shortnum,
  1434.                   &plyr->maxammo[2],
  1435.                   &st_statusbaron,
  1436.                   ST_MAXAMMO2WIDTH);
  1437.     
  1438.     STlib_initNum(&w_maxammo[3],
  1439.                   ST_MAXAMMO3X,
  1440.                   ST_MAXAMMO3Y,
  1441.                   shortnum,
  1442.                   &plyr->maxammo[3],
  1443.                   &st_statusbaron,
  1444.                   ST_MAXAMMO3WIDTH);
  1445.  
  1446. }
  1447.  
  1448. static boolean  st_stopped = true;
  1449.  
  1450.  
  1451. void ST_Start (void)
  1452. {
  1453.  
  1454.     if (!st_stopped)
  1455.         ST_Stop();
  1456.  
  1457.     ST_initData();
  1458.     ST_createWidgets();
  1459.     st_stopped = false;
  1460.  
  1461. }
  1462.  
  1463. void ST_Stop (void)
  1464. {
  1465.     if (st_stopped)
  1466.         return;
  1467.  
  1468.     I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE), 0);
  1469.  
  1470.     st_stopped = true;
  1471. }
  1472.  
  1473. void ST_Init (void)
  1474. {
  1475.     veryfirsttime = 0;
  1476.     ST_loadData();
  1477.     screens[4] = (byte *) Z_Malloc(SCREENWIDTH*ST_HEIGHT, PU_STATIC, 0);
  1478. }
  1479.